/**
 * Charts1：仪表盘
 */
import React  from 'react'
import style from './index.less'
import ReactMarkdown from 'react-markdown';
import { Collapse ,Rate } from 'antd'
const Panel = Collapse.Panel

import Profit from '../Profit'

const collapseStyle={
  background:'none',
}
const panelStyle = {
  background:'rgba(51, 153, 255, 0.25)',
  marginBottom: 24,
  border: 0,
  overflow: 'hidden',
}

export default ({info,notesConfig,details})=>{
  const panelArr=[
    {
      title:"盈利能力",
      subTitle:()=>{
        let titles=''
        const subTitles=[
          {
            id:"profitability",
            value:info.profitability&&info.profitability.toFixed(2),
            valueArr:notesConfig.dimension_pivots.profitability,
            comment:notesConfig.comment_text.profitability
          },
          {
            id:"eff_sharpe_ratio",
            value:info.effSharpeRatio&&info.effSharpeRatio.toFixed(2),
            valueArr:notesConfig.feature_pivots.eff_sharpe_ratio,
            comment:notesConfig.comment_text.eff_sharpe_ratio
          },
          {
            id:"pnl_efficiency",
            value:info.pnlEfficiency&&info.pnlEfficiency.toFixed(2),
            score:info.scorePnlEfficiency&&info.scorePnlEfficiency.toFixed(2),
            trigger:notesConfig.diagnosis_features.pnl_efficiency.trigger,
            comment:notesConfig.diagnosis_features.pnl_efficiency.comments
          },
          {
            id:"win_ratio",
            value:info.winRatio&&info.winRatio.toFixed(2),
            score:info.scoreWinRatio&&info.scoreWinRatio.toFixed(2),
            trigger:notesConfig.diagnosis_features.win_ratio.trigger,
            comment:notesConfig.diagnosis_features.win_ratio.comments
          },
          {
            id:"streak",
            value:info.streak&&info.streak.toFixed(2),
            score:info.scoreStreak&&info.scoreStreak.toFixed(2),
            trigger:notesConfig.diagnosis_features.streak.trigger,
            comment:notesConfig.diagnosis_features.streak.comments
          },
          {
            id:"all_time_pnl",
            value:info.allTimePnl&&info.allTimePnl.toFixed(2),
            score:info.scoreAllTimePnl&&info.scoreAllTimePnl.toFixed(2),
            trigger:notesConfig.diagnosis_features.all_time_pnl.trigger,
            comment:notesConfig.diagnosis_features.all_time_pnl.comments
          }
        ]
        if(notesConfig){
          subTitles.map((item,i)=>{
            if(item.value&&((item.trigger&&item.score<item.trigger)||!item.trigger)){
              titles+=checkout(item)
            }
          })
        }
        return titles
      },
      rate:info.profitability&&(parseInt(info.profitability/10)/2),
      children:<Profit info={info} notesConfig={notesConfig} details={details} />
    }
  ]

  return (
    <Collapse
       bordered={false}
       style={collapseStyle}
      // defaultActiveKey={['1']}
      >
        {
          panelArr.map((item)=>(
            <Panel
              header={
                <div className={style.title}>
                  <span><i className="icon iconfont icon-thfx-meiyuan"></i>{item.title}</span>
                  <Rate
                    disabled
                    defaultValue={item.rate}
                    allowHalf
                    style={{ fontSize: 28 }}
                   />
                  <ReactMarkdown source={item.subTitle()} />
                </div>}
              key="1"
              style={panelStyle}
              bordered={true}
              >
                {item.children}
            </Panel>
          ))
        }


    </Collapse>
  )
}
